#include<iostream>
using namespace std;
bool LeadYear(const int year){
    return (!(year % 4) && (year % 100)) || !(year % 400);
}
int main(){
    int year,month,day;
    int sum = 0;
    int day_month[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    while(cin>>year>>month>>day){
        //[1,month)求和
      for(int i = 0; i < month; i++){
        sum += day_month[i];   
      }
        sum += day;
        //+day
        if(LeadYear(year) && month >= 3)
            sum += 1;
    }
    cout << sum << endl;
    return 0;    
}
